<?php
class Core_Dice_Validate
	extends Zend_Validate_Abstract
{
	const MATCH 	= 'match';
	const MAX		= 'maxLength';
	const MIN		= 'minLength';
	const LENGTH	= 15;
	
	protected $_messageTemplates = array(
			self::MATCH	=> "%value% does not match a valid Dice Roll",
			self::MAX	=> "%value% is too long",
			self::MIN	=> "%value% is too short" ); 
			
	public function isValid($value)
	{
		Zend_Loader::loadClass('Core_Dice');
		//make a change
		$this->_setValue($value);
		$isValid	= true;
		if (strlen($value) < 1)
		{
			$this->_error(self::MIN);
			$isValid	= false;
		}
		
		if (strlen($value) > self::LENGTH)
		{
			$this->_error(self::MAX);
			$isValid	= false;	
		}
		
		if (preg_match(Core_Dice::REGEX, $value) < 1)
		{
			$this->_error(self::MATCH);
			$isValid	= false;
		}
		
		return $isValid;
	}
}